package cdu.sl.mapper;

import cdu.sl.annotation.AutoFill;
import cdu.sl.common.enums.OperationType;
import cdu.sl.domain.po.AssignmentProgress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 学习任务进度Mapper接口
 */
@Mapper
public interface AssignmentProgressMapper extends BaseMapper<AssignmentProgress> {

    @AutoFill(OperationType.INSERT)
    int insert(AssignmentProgress entity);

    /**
     * 根据班级ID和用户ID查询学习进度
     * @param classId 班级ID
     * @param userId 用户ID
     * @return 学习进度列表
     */
    @Select("SELECT * FROM tb_assignment_progress WHERE class_id = #{classId} AND user_id = #{userId}")
    List<AssignmentProgress> selectByClassIdAndUserId(@Param("classId") Long classId, @Param("userId") Long userId);

    /**
     * 根据班级学习集关联ID和用户ID查询学习进度
     * @param classStudySetId 班级学习集关联ID
     * @param userId 用户ID
     * @return 学习进度
     */
    @Select("SELECT * FROM tb_assignment_progress WHERE class_study_set_id = #{classStudySetId} AND user_id = #{userId} LIMIT 1")
    AssignmentProgress selectByClassStudySetIdAndUserId(@Param("classStudySetId") Long classStudySetId, @Param("userId") Long userId);

    /**
     * 根据班级学习集关联ID查询所有学生的学习进度
     * @param classStudySetId 班级学习集关联ID
     * @return 学习进度列表
     */
    @Select("SELECT * FROM tb_assignment_progress WHERE class_study_set_id = #{classStudySetId}")
    List<AssignmentProgress> selectByClassStudySetId(@Param("classStudySetId") Long classStudySetId);

} 